package com.projecthost.wizaz.model;

import java.io.Serializable;
import java.util.Arrays;

public class ProductDetailed extends ProductBase implements Serializable {

    private static final long serialVersionUID = 7661555519298396872L;
    private final String categoryUrl;
    private final String imageUrl;
    private final String brand;
    private final String description;
    private final Float averageRating;
    private final Integer[] starsDistribution;

    public ProductDetailed(Integer productId, String name, String brand, String categoryUrl, String description,
            Integer myHitCount, Float averageRating, Integer reviewCount, Integer[] starsDistribution) {
        super(productId, name, myHitCount, 0.5f * Math.round(averageRating / 0.5f), reviewCount);
        this.categoryUrl = categoryUrl;
        this.imageUrl = "foto/" + productId + "_250.jpg";
        this.brand = brand;
        this.description = description;
        this.averageRating = averageRating;
        this.starsDistribution = starsDistribution;
    }

    public String getCategoryUrl() {
        return categoryUrl;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public String getBrand() {
        return brand;
    }

    public String getDescription() {
        return description;
    }

    public Float getAverageRating() {
        return averageRating;
    }

    public Integer[] getStarsDistribution() {
        return starsDistribution;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("ProductDetailed [productId=");
        builder.append(getProductId());
        builder.append(", name=");
        builder.append(getName());
        builder.append(", categoryUrl=");
        builder.append(categoryUrl);
        builder.append(", imageUrl=");
        builder.append(imageUrl);
        builder.append(", brand=");
        builder.append(brand);
        builder.append(", description=");
        builder.append(description);
        builder.append(", averageRating=");
        builder.append(averageRating);
        builder.append(", starsDistribution=");
        builder.append(Arrays.toString(starsDistribution));
        builder.append(", getMyHitCount()=");
        builder.append(getMyHitCount());
        builder.append(", getStarRating()=");
        builder.append(getStarRating());
        builder.append(", getReviewCount()=");
        builder.append(getReviewCount());
        builder.append("]");
        return builder.toString();
    }

}
